<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2018/9/29
 * Time: 11:51
 */

namespace app\index\controller;

# 模板测试
use think\Controller;
use think\facade\View;
use think\Db;

class Demo2 extends Controller
{
    # 页面输出
    public function test1(){
        $content = '<h3 style="color:blue">hello world!</h3>';
//        return $this->display($content);
//        return $this->view->display($content);
        return View::display($content);
    }

    # 依赖注入页面输出
    public function test2(\think\View $view){
        $content = '<h3 style="color:#321;">hello world!</h3>';
//        return $this->display($content);
//        return $this->view->display($content);
        return $view->display($content);
    }

    # 使用视图将数据输出
    public function test3(){
        $this->assign('name', '剋剋打开');
        $admin = Db::name('admin')->find(46);
        $this->assign('admin', $admin);
        $cls = new \stdClass();
        $cls->name = '的肯定';
        $cls->age = 33;
        $this->assign('cls', $cls);
        define('CUR_NUMBER',333);
        session('b2','2b');
        return $this->view->fetch();
    }
}